#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

int main() {
    int year = 0;
    int month = 0;
    int day = 0;
    scanf("%d-%d-%d", &year, &month, &day);
    int flag = 0;
    if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
        flag = 1;
    }
    if (flag) {
        switch (month) {
        case 1:
            printf("%d", day);
            break;
        case 2:
            day += 31;
            printf("%d", day);
            break;
        case 3:
            day += (31 + 29);
            printf("%d", day);
            break;
        case 4:
            day += (31 + 29 + 31);
            printf("%d", day);
            break;
        case 5:
            day += (31 + 29 + 31 + 30 + 31);
            printf("%d", day);
            break;
        case 6:
            day += (31 + 29 + 31 + 30 + 31 + 30);
            printf("%d", day);
            break;
        case 7:
            day += (31 + 29 + 31 + 30 + 31 + 30 + 31);
            printf("%d", day);
            break;
        case 8:
            day += (31 + 29 + 31 + 30 + 31 + 30 + 31 + 31);
            printf("%d", day);
            break;
        case 9:
            day += (31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30);
            printf("%d", day);
            break;
        case 10:
            day += (31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31);
            printf("%d", day);
            break;
        case 11:
            day += (31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30);
            printf("%d", day);
            break;
        case 12:
            day += (31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31);
            printf("%d", day);
            break;
        }
    }
    else {
        switch (month) {
        case 1:
            printf("%d", day);
            break;
        case 2:
            day += 31;
            printf("%d", day);
            break;
        case 3:
            day += (31 + 28);
            printf("%d", day);
            break;
        case 4:
            day += (31 + 28 + 31);
            printf("%d", day);
            break;
        case 5:
            day += (31 + 28 + 31 + 30 + 31);
            printf("%d", day);
            break;
        case 6:
            day += (31 + 28 + 31 + 30 + 31 + 30);
            printf("%d", day);
            break;
        case 7:
            day += (31 + 28 + 31 + 30 + 31 + 30 + 31);
            printf("%d", day);
            break;
        case 8:
            day += (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31);
            printf("%d", day);
            break;
        case 9:
            day += (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30);
            printf("%d", day);
            break;
        case 10:
            day += (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31);
            printf("%d", day);
            break;
        case 11:
            day += (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30);
            printf("%d", day);
            break;
        case 12:
            day += (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31);
            printf("%d", day);
            break;
        }
    }
    return 0;
}